<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title>创建报价单</title>
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
    <script src="${ctxStatic}/js/jquery-1.9.1.min.js"></script>
    <script src="${ctxStatic}/js/DateTimePicker.js"></script>
    <script src="${ctxStatic}/js/layer.js"></script>
    <script src="${ctxStatic}/js/style.js"></script>
    <script src="${ctxStatic}/dateCalendar/WdatePicker.js"></script>
    <link rel="stylesheet" href="${ctxStatic}/css/common.css">
    <link rel="stylesheet" href="${ctxStatic}/css/layerSm.css">
    <c:set value="<%=ResourcesUtil.getConfig(\"audit_uncommit\") %>" var="audit_00"/>
    <script>
    $(function(){
            $(".tabBox ul li").each(function(){
                var index=$(this).index();

                $(".tabBox ul li").eq(0).addClass("active");

                $(this).click(function(){

                    //alert(index);

                    $(this).addClass("active").siblings().removeClass("active");

                    $(".tabBoxSm > .tabSm").eq(index).stop(true).show().siblings().stop(true).hide();
					
					var tableW = $(".tabBoxSm > .tabSm").eq(index).find('.tableHead').width();
					var tabodyH = $(".tabBoxSm > .tabSm").eq(index).find('.tableBody').height();
					var tableScrollH = $(".tabBoxSm > .tabSm").eq(index).find('.tableScroll').height();
					if(tabodyH>tableScrollH){
						$(".tabBoxSm > .tabSm").eq(index).find('.tableScroll').css('width',tableW + 18 + 'px')
					}else{
						$(".tabBoxSm > .tabSm").eq(index).find('.tableScroll').css('width','inherit')
					}

                })

            })

        })
        
        /*  提交  */
    function commitContract(){
    	if (confirm("<spring:message code="puttingContract_edit_areYouSureCommit"/>")) {
    		var id = $("#id").val();
    		var param = {"id":id};
    		$.post("${ctx}/putting/contract/commit",param,function(result){
    			/* 弹出提示框,刷新父页面,关闭当前页面 */
    			tipParent(result.message);
    			 window.parent.frames[0].searchListForm();
    			closeWin();
    		},'json');
    	}
    }
    /* 删除  */
    function deleteContract(){
    	if (confirm("<spring:message code="puttingContract_edit_areYouSureDelete"/>")) {
    		var id = $("#id").val();
    		var param = {"id":id};
    		$.post("${ctx}/putting/contract/delete",param,function(result){
    			/* 弹出提示框,刷新父页面,关闭当前页面 */
    			tipParent(result.message);
    			 window.parent.frames[0].searchListForm();
    			closeWin();
    		},'json');
    	}
    }
    function excelExport() {
    	$("#inputForm").submit();
    }
        
    </script>
    <style type="text/css">
    							.tab-wfcz{width: 40px;}
    							.tab-wfkstp{width: 60px;}
		                        .tab-wfkhksmc{width: 150px;}
		                        .tab-wfkslb{width: 80px;}
		                        .tab-wfhtddh{width: 100px;}
		                        .tab-wfkh{width: 120px;}
		                        .tab-wfddsl{width: 80px;}
		                        .tab-wfsl{width: 100px;}
		                        .tab-wfjgf{width: 100px;}
		                        .tab-wfcjr{width: 80px;}
		                        .tab-wfcjsj{width: 100px;}
   
    
    .w-650{
	width:650px;
	}
	.w-65{
	width:65px;
	}
    </style>
</head>
<body>
<!-- 查看头部 -->   
<div class="layerHeader clearfix">
	<p class="headerTitle"><spring:message code="puttingContract_edit_viewContract"/></p>
    <div class="headerButton clearfix">
    <button type="button" onclick="excelExport();"><spring:message code="putting_contract_download"/></button>
    <c:if test="${puttingContract.deleteFlag == 0 }">
    	<c:if test="${puttingContract.contractAuditStatus == audit_00 }">
   	 	<!-- 提交按钮 -->
   	 	<shiro:hasPermission name="putting:contract:edit">
    		<button type="button" onclick="commitContract();"><spring:message code="puttingContract_edit_commit"/></button>
  		</shiro:hasPermission>
  		</c:if>
   	 	<c:if test="${puttingContract.contractAuditStatus != audit_00 }">
    	<!-- 审核按钮 -->
    	<shiro:hasPermission name="putting:contract:audit">
    		<button type="button" onclick="popup('800px','519px','${ctx}/putting/contract/audit?id=${puttingContract.id }')"><spring:message code="puttingContract_edit_audit"/></button>
    	</shiro:hasPermission>
    	</c:if>
    	<c:if test="${puttingContract.contractAuditStatus == audit_00 }">
    	<shiro:hasPermission name="putting:contract:edit">
	    	<!-- 删除按钮 -->
	        <button type="button" onclick="deleteContract();"><spring:message code="puttingContract_edit_delete"/></button>
	        <!-- 编辑按钮 -->
	        <button type="button" onclick="window.location.href='${ctx}/putting/contract/editContract?id=${puttingContract.id}'"><spring:message code="puttingContract_edit_edit"/></button>
        </shiro:hasPermission>
        </c:if>
     </c:if>
        <button type="button" onclick="closeWin()"><spring:message code="puttingContract_edit_cancle"/></button>
    </div>
</div>
<form id="inputForm" ACTION="${ctx}/putting/contract/exportFile" method="post">
<input type="hidden" name="ognizationNameA" value="${puttingContract.ognizationNameA }"/>
<input type="hidden" name="ognizationNameB" value="${puttingContract.ognizationNameB }"/>
<input type="hidden" name="ognizationAddressA" value="${puttingContract.ognizationAddressA }"/>
<input type="hidden" name="ognizationAddressB" value="${puttingContract.ognizationAddressB }"/>
<input type="hidden" name="legalPersonA" value="${puttingContract.legalPersonA }"/>
<input type="hidden" name="contactPersonA" value="${puttingContract.contactPersonA }"/>
<input type="hidden" name="legalPersonB" value="${puttingContract.legalPersonB }"/>
<input type="hidden" name="contactPersonB" value="${puttingContract.contactPersonB }"/>
<input type="hidden" name="contactPhoneA" value="${puttingContract.contactPhoneA }"/>
<input type="hidden" name="contactFaxA" value="${puttingContract.contactFaxA }"/>
<input type="hidden" name="contactPhoneB" value="${puttingContract.contactPhoneB }"/>
<input type="hidden" name="contactFaxB" value="${puttingContract.contactFaxB }"/>
<input type="hidden" name="contactEmailA" value="${puttingContract.contactEmailA }"/>
<input type="hidden" name="contactEmailB" value="${puttingContract.contactEmailB }"/>
<input type="hidden" name="paymentWay" value="${fns:getDictName(puttingContract.paymentWay) }"/>
<input type="hidden" name="contractStatus" value="${fns:getDictName(puttingContract.contractStatus) }"/>
<input type="hidden" name="contractMaterialQuantity" value="${puttingContract.contractMaterialQuantity }"/>
<input type="hidden" name="contractAmount" value="${puttingContract.contractAmount }"/>
<input type="hidden" name="contractDateTime" value="<fmt:formatDate value="${puttingContract.contractDateTime }" pattern="yyyy-MM-dd" />"/>
<input type="hidden" name="contractDeliveryDate" value="<fmt:formatDate value="${puttingContract.contractDeliveryDate }" pattern="yyyy-MM-dd" />"/>
<input type="hidden" name="specialExplain" value="${puttingContract.specialExplain }"/>
<input type="hidden" name="contractClause" value="${puttingContract.contractClause }"/>
<input type="hidden" name="createBy.firstName" value="${puttingContract.createBy.firstName }"/>
<input type="hidden" name="createDate" value="<fmt:formatDate value="${puttingContract.createDate }" pattern="yyyy-MM-dd" />"/>
<input type="hidden" name="contractProcessNO" value="${puttingContract.contractProcessNO }"/>

<div class="tabBox">
    <ul class="clearfix">
     	<li class="active" style="width: 100px"><spring:message code="puttingContract_edit_contractMessage"/></li>
        <li style="width: 110px"><spring:message code="puttingContract_edit_styleList"/></li>
    </ul>
    
</div>
<div  class="tabBoxSm">
    <div class="tabSm smOrderBox showHtml">
    <input type="hidden" id="id" name="id" value="${puttingContract.id }"/>
        <div class="items clearfix">
            <div class="col-50 clearfix haveToBox">
                <p class="tit"><spring:message code="puttingContract_edit_companyA"/></p>
                <input id="" name="" value="${puttingContract.ognizationNameA }" style="width: 315px">
                <button type="button" onclick=""><spring:message code="quotation_create_select"/></button>
                <p class="haveTo">*</p>
            </div>
            <div class="col-50 clearfix">
                <p class="tit"><spring:message code="puttingContract_edit_companyB"/></p>
                <input id="" name=""   value="${puttingContract.ognizationNameB }" style="width: 315px">
                <button type="button" onclick=""><spring:message code="quotation_create_select"/></button>
            </div>
        </div>
        <div class="items clearfix">
            <div class="col-50 clearfix">
                <p class="tit"><spring:message code="puttingContract_edit_address"/></p>
                <input id="" name=""  value="${puttingContract.ognizationAddressA }" style="width: 315px">
            </div>
            <div class="col-50 clearfix">
                <p class="tit"><spring:message code="puttingContract_edit_address"/></p>
                <input id="" name=""  value="${puttingContract.ognizationAddressB }" style="width: 315px">
            </div>
        </div>
        <div class="items clearfix">
            <div class="col-50 clearfix">
          		<div class="left clearfix">
                	<p class="tit"><spring:message code="puttingContract_edit_legalPerson"/></p>
                	<input id="" name="" value="${puttingContract.legalPersonA }" style="width: 110px">
            	</div>
            	<div class="right clearfix" style="margin-right: 100px;">
                	<p class="tit"><spring:message code="puttingContract_edit_contactPerson"/></p>
                	<input id="" name=""  value="${puttingContract.contactPersonA }" style="width: 110px">
            	</div>
            </div>
            <div class="col-50 clearfix">
            	<div class="left clearfix">
                	<p class="tit"><spring:message code="puttingContract_edit_legalPerson"/></p>
                	<input id="" name=""  value="${puttingContract.legalPersonB }" style="width: 110px">
            	</div>
            	<div class="right clearfix" style="margin-right: 100px;">
                	<p class="tit"><spring:message code="puttingContract_edit_contactPerson"/></p>
               		<input id="" name=""  value="${puttingContract.contactPersonB }" style="width: 110px">
            	</div>
            </div>
        </div>
        <div class="items clearfix">
            <div class="col-50 clearfix">
            	<div class="left clearfix">
                	<p class="tit"><spring:message code="puttingContract_edit_contactPhone"/></p>
                	<input id="" name=""  value="${puttingContract.contactPhoneA }" style="width: 110px">
            	</div>
            	<div class="right clearfix" style="margin-right: 100px;">
                	<p class="tit"><spring:message code="puttingContract_edit_contactFax"/></p>
               		<input id="" name=""  value="${puttingContract.contactFaxA }" style="width: 110px">
            	</div>
            </div>
            <div class="col-50 clearfix">
            	<div class="left clearfix">
                	<p class="tit"><spring:message code="puttingContract_edit_contactPhone"/></p>
                	<input id="" name=""  value="${puttingContract.contactPhoneB }" style="width: 110px">
            	</div>
            	<div class="right clearfix" style="margin-right: 100px;">
                	<p class="tit"><spring:message code="puttingContract_edit_contactFax"/></p>
               		<input id="" name=""  value="${puttingContract.contactFaxB }" style="width: 110px">
            	</div>
            </div>
        </div>
        <div class="items clearfix">
            <div class="col-50 clearfix">
                <p class="tit"><spring:message code="puttingContract_edit_contactEmail"/></p>
                <input id="" name="" value="${puttingContract.contactEmailA }" style="width: 315px">
            </div>
            <div class="col-50 clearfix">
                <p class="tit"><spring:message code="puttingContract_edit_contactEmail"/></p>
                <input id="" name=""   value="${puttingContract.contactEmailB }" style="width: 315px">
            </div>
        </div>
        <div class=" clearfix" >
        	<p class="title" style="margin-top: 2px"><spring:message code="puttingContract_edit_contractBasicMessage"/></p>
        </div>
        <div class="clearfix">
        	<div class="left w-650">
            	<div class="items clearfix">
            	<div class="col-50 clearfix haveToBox">
                    <!-- 付款方式  -->
                        <p class="tit"><spring:message code="puttingContract_edit_paymentWay"/></p>
                        <input  value="${fns:getDictName(puttingContract.paymentWay) }">
                        <p class="haveTo">*</p>
                    </div>        	
                    <div class="col-50 clearfix haveToBox">
                    <!-- 合同状态  -->
                        <p class="tit"><spring:message code="puttingContract_edit_contractStatus"/></p>
                        <input id="" name=""  value="${fns:getDictName(puttingContract.contractStatus) }">
						<p class="haveTo">*</p>
                    </div>
                </div>
                <div class="items clearfix">        	
                    <div class="col-50 clearfix haveToBox">
                    <!-- 外发加工数量 -->
                        <p class="tit" style="width: 80px"><spring:message code="puttingContract_edit_contractQuantity"/></p>
                        <input id="" name=""  value="${puttingContract.contractMaterialQuantity }">
                        <p class="haveTo">*</p>
                    </div>
                    <div class="col-50 clearfix haveToBox">
                    <!-- 外发加工金额  -->
                        <p class="tit" style="width: 80px"><spring:message code="puttingContract_edit_contractAmount"/></p>
                        <input id="" name=""  value="${puttingContract.contractAmount }">
                        <p class="haveTo">*</p>
                    </div>
                </div>
                <div class="items clearfix">        	
                    <div class="col-50 clearfix haveToBox">
                    <!-- 签订日期  -->
                        <p class="tit"><spring:message code="puttingContract_edit_contractDateTime"/></p>
                        <input type="text"  value="<fmt:formatDate value="${puttingContract.contractDateTime }" pattern="yyyy-MM-dd" />">
                        <p class="haveTo">*</p>
                    </div>
                    <div class="col-50 clearfix haveToBox">
                    <!-- 预计交货日期  -->
                        <p class="tit" style="width: 80px"><spring:message code="puttingContract_edit_contractEndDate"/></p>
                        <input type="text"  value="<fmt:formatDate value="${puttingContract.contractDeliveryDate }" pattern="yyyy-MM-dd" />">
                        <p class="haveTo">*</p>
                    </div>
                </div>
            </div>
            <div class="w-330">
                <div class="items clearfix">     
                    <!-- 特殊说明  -->
                    <p class="tit"><spring:message code="puttingContract_edit_specialExplain"/></p>
                    <textarea id="" name="" style="width:220px;height: 105px">${puttingContract.specialExplain }</textarea>
                </div>
            </div>
        </div>
        <div class="items clearfix">        	
            <div class="left w-65 clearfix">
           <!-- 合同条款 -->
                <p class="tit"><spring:message code="puttingContract_edit_contractClause"/></p>
                <button type="button" onclick=""><spring:message code="quotation_create_select"/></button>
                </div>
                <div class="clearfix">
                <textarea id="" name="" style="width:870px;height: 140px">${puttingContract.contractClause }</textarea>
            </div>
        </div>
        <div class="w-500 items clearfix">
            <div class="col-50 clearfix">
            <!-- 创建人员 -->
                <p class="tit"><spring:message code="puttingContract_edit_creator"/></p>
                <input id="" name="" value="${puttingContract.createBy.firstName }" >
            </div>
            <div class="col-50 clearfix">
            <!-- 创建时间 -->
                <p class="tit"><spring:message code="puttingContract_edit_createDate"/></p>
                <input id="" name=""   value="<fmt:formatDate value="${puttingContract.createDate }" pattern="yyyy-MM-dd" />" >
            </div>
        </div>
	</div>
    <div class="tabSm none">
    	<div class="tableArea">
        	<div class="tableScrollSm" style="overflow: auto;width: 988px;height: 520px">
        		<table cellpadding="0" class="tableHead">
                    <thead>
                    <tr>
                        <th class="tab-wfkstp"><spring:message code="puttingContract_edit_styleImage"/></th>
                        <th class="tab-wfkhksmc"><spring:message code="puttingContract_edit_styleNameNO"/></th>
                        <th class="tab-wfkslb"><spring:message code="puttingContract_edit_styleCategory"/></th>
                        <th class="tab-wfhtddh"><spring:message code="puttingContract_edit_contractNO"/></th>
                        <th class="tab-wfkh"><spring:message code="puttingContract_edit_customerName"/></th>
                        <th class="tab-wfddsl"><spring:message code="puttingContract_edit_orderQuantity"/></th>
                        <th class="tab-wfsl"><spring:message code="puttingContract_edit_puttingQuantity"/></th>
                        <th class="tab-wfjgf"><spring:message code="puttingContract_edit_cost"/></th>
                        <th class="tab-wfcjr"><spring:message code="puttingContract_edit_styleCreator"/></th>
                        <th class="tab-wfcjsj"><spring:message code="puttingContract_edit_stylecreateDate"/></th>
                    </tr>
                    </thead>
                </table>
                <table  cellpadding="0" class="tableBody" id="materialTable">
                    <tbody id="listHtml">
                    <c:forEach items="${puttingContract.styleList }" var="style" varStatus="status">
                    <tr>
                        <td class="tab-wfkstp"><c:if test="${style.styleFile!=null && style.styleFile!='' }"><img src="${style.styleFile }" class="wltp"></c:if><c:if test="${style.styleFile==null||style.styleFile=='' }"><img src="${ctxStatic}/images/pic-none.jpg" class="wltp"></c:if></td>
                        <td class="tab-wfkhksmc">${style.styleCustomerNo }<br>${style.styleNameCN }</td>
                        <td class="tab-wfkslb">${fns:getDictName(style.styleCatgoryCD) }</td>
                        <td class="tab-wfhtddh">${style.customerContractNO }</td>
                        <td class="tab-wfkh">${style.styleCustomerName }</td>
                        <td class="tab-wfddsl">${style.indentQuantity}</td>
                        <td class="tab-wfsl">${style.contractQuantity}</td>
                        <td class="tab-wfjgf">${style.contractProcessCost}</td>
                        <td class="tab-wfcjr">${style.createBy.firstName}</td>
                        <td class="tab-wfcjsj"><fmt:formatDate value="${style.createDate}" pattern="yyyy-MM-dd" /></td>
                        
                        <input type="hidden" name="styleList[${status.index}].styleCustomerNo" value="${style.styleCustomerNo}"/>
                        <input type="hidden" name="styleList[${status.index}].styleNameCN" value="${style.styleNameCN}"/>
                        <input type="hidden" name="styleList[${status.index}].styleCatgoryCD" value="${fns:getDictName(style.styleCatgoryCD) }"/>
                        <input type="hidden" name="styleList[${status.index}].customerContractNO" value="${style.customerContractNO }"/>
                        <input type="hidden" name="styleList[${status.index}].styleCustomerName" value="${style.styleCustomerName }"/>
                        <input type="hidden" name="styleList[${status.index}].indentQuantity" value="${style.indentQuantity}"/>
                        <input type="hidden" name="styleList[${status.index}].contractQuantity" value="${style.contractQuantity}"/>
                        <input type="hidden" name="styleList[${status.index}].contractProcessCost" value="${style.contractProcessCost}"/>
                        <input type="hidden" name="styleList[${status.index}].createBy.firstName" value="${style.createBy.firstName}"/>
                        <input type="hidden" name="styleList[${status.index}].createDate" value="<fmt:formatDate value="${style.createDate}" pattern="yyyy-MM-dd" />"/>
                        
                    </tr>
                    </c:forEach>
                    </tbody>
                </table>
                <div id="hiddenHtml"></div>
            </div>
        </div>
    </div>
</div>
</form>
<script>
	window.onload = function(){
			var windowH = window.innerHeight
					||document.documentElement.clientHeight
					||document.body.clientHeight
			$('.tabSm').css({
				'height':windowH - 77,
			});
			$('.tableScrollSm').css({
				'height':windowH - 91
			})
		}
	$('.squareL').on('click', function() {
	    var lastCon = $('.square ol li:last-child').detach();
	    $('.square ol').prepend(lastCon)
	    $('.square ol li:last-child').addClass('active')
	    $('.square ol li:last-child').siblings().removeClass('active')
	})

	$('.squareR').on('click', function() {
	    var lastCon = $('.square ol li:first-child').detach();
	    $('.square ol').append(lastCon)
	    $('.square ol li:last-child').addClass('active')
	    $('.square ol li:last-child').siblings().removeClass('active')
	})
	$('.showHtml').find('input,select,textarea').attr('disabled','disabled');
</script>
</body>
</html>
